package com.zk.aop;

import java.util.List;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.zk.schedule.WebServiceSchedule;


/**
 * 机构信息推送服务切面
 * @author pfan
 *
 */
@Component
@Aspect
public class OrganizationServiceAspect {

	private Logger logger = LoggerFactory.getLogger(OrganizationServiceAspect.class);
	
	@Autowired
	private WebServiceSchedule wsSchedule;
	
	/**
	 * 新增机构信息和科室信息切点
	 * 						com.sinosoft.framework.core.service.manager.IdentityManager.addIdentityInformation(..))
	 */
	@Pointcut("execution(* com.sinosoft.framework.core.service.manager.GroupManager.addGroup(..))")
	public void pointCut_group() {}
	
	
	
	/**
	 * 新增
	 * @param jp
	 * @param result
	 */
	@SuppressWarnings("unchecked")
	@AfterReturning(pointcut="pointCut_group()", returning="result")
	public void afterAddOrganizationAndDept(JoinPoint jp, boolean result) {
		if(result) {
			logger.debug("开始执行新增机构切点的推送操作：");
			//GroupEntity groupEntity = (GroupEntity) jp.getArgs()[0];
			//List<DepartmentEntity> departmentEntities = (List<DepartmentEntity>) jp.getArgs()[1];
//			IdentityInformationEntity iden = (IdentityInformationEntity) jp.getArgs()[0];
			wsSchedule.pushOrganizationInfoLists();
			logger.debug("结束执行新增机构切点的推送操作！");
		}
	}
}
